﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace WcfContrib.Client.Behaviors
{
    /// <summary>
    /// Represents a provider interface for managing communication channels
    /// </summary>
    public interface IChannelProvider
    {
        /// <summary>
        /// Gets the communication channel.
        /// </summary>
        /// <param name="factory">The channel factory.</param>
        /// <param name="mode">The context mode.</param>
        /// <param name="isCreated">if set to <c>true</c>, the channel had just been created.</param>
        /// <returns></returns>
        ICommunicationObject GetChannel(ChannelFactory factory, ChannelContextMode mode, out bool isCreated);

        /// <summary>
        /// Aborts the communication channel.
        /// </summary>
        /// <param name="channel">The communication channel.</param>
        /// <param name="mode">The context mode.</param>
        void AbortChannel(object channel, ChannelContextMode mode);

        /// <summary>
        /// Closes the communication channel.
        /// </summary>
        /// <param name="channel">The communication channel.</param>
        /// <param name="mode">The context mode.</param>
        void CloseChannel(object channel, ChannelContextMode mode);

        /// <summary>
        /// Closes the communication channel asynchronously.
        /// </summary>
        /// <param name="channel">The communication channel.</param>
        /// <param name="mode">The context mode.</param>
        /// <param name="timeoutInSeconds">The timeout in seconds.</param>
        void CloseChannelAsync(object channel, ChannelContextMode mode, int timeoutInSeconds);

        /// <summary>
        /// Terminates the communication channel.
        /// </summary>
        /// <param name="channel">The communication channel.</param>
        /// <param name="mode">The context mode.</param>
        void TerminateChannel(object channel, ChannelContextMode mode);
    }
}
